package com.sunyzc.ebaotech.simulator.ybt.ccbnew;

import com.sunyzc.ebaotech.simulator.ybt.AbstractYBTProcessor;

/**
 * 该Processor不可直接用于环境中的CCBNEW银行的交易，交易模拟的方式与其他银行一致，也与测试用的模拟机方式一致，需修改银保通服务器配置： <br>
 * - <b>BizFlowConfig.xml: </b>修改CCBNEW CLIENT下的TRANS配置，需要对每个交易分别配置，而不是使用ALL <br>
 * - <b>MessageConfig.xml: </b>修改ID为39871的SERVERCONFIG，修改编码、报文头等配置 <br>
 * - <b>CcbNewProtocol.java: </b>删除该类下的所有方法和变量 <br>
 * P53816141 - 保费试算(104) <br>
 * P53819113 - 核保(101) <br>
 * P53819152 - 新单缴费(102) <br>
 */
public class CCBNEWProcessor extends AbstractYBTProcessor {
	private final static int HEAD_LENGTH = 21;
	private final static int BODY_LENGTH_BEGIN_INDEX = 0;
	private final static int BODY_LENGTH_END_INDEX = 6;

	@Override
	public byte[] generateHeadBytes(String requestTransType, byte[] bodyContent) throws Exception {
		String contentLength = (bodyContent == null ? 0 : bodyContent.length) + "";
		while (contentLength.length() < 6)
			contentLength = contentLength + " ";
		String requestHeadContent = contentLength + requestTransType + "001   ";
		return requestHeadContent.getBytes(getClientConfig().getTransEncoding());
	}

	@Override
	protected int getHeadLength() {
		return HEAD_LENGTH;
	}

	@Override
	protected int getBodyLengthBeginIndex() {
		return BODY_LENGTH_BEGIN_INDEX;
	}

	@Override
	protected int getBodyLengthEndIndex() {
		return BODY_LENGTH_END_INDEX;
	}
}
